const btnClick = () => {
  // 获取导航栏的元素
  const nav = document.getElementById('nav');
  console.log(nav);
  console.log(nav.classList);
  nav.classList.toggle('active');
  nav.classList.add('css1');
  console.log(nav.classList);

  // 对象数组去重
  var arr = [
    { id: 1, name: 'test1' },
    { id: 2, name: 'test2' },
    { id: 3, name: 'test3' },
    { id: 1, name: '张三1' },
    { id: 2, name: '张三2' },
    { id: 3, name: '张三3' },
  ];
  let newobj = {};
  arr = arr.reduce((total, currentValue) => {
    newobj[currentValue.id]
      ? ''
      : (newobj[currentValue.id] = total.push(currentValue));
    return total;
  }, []);
  console.log(arr);
};
